﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;

public class Icon_HeroSetting : MonoBehaviour
{
    public bool isDoubleRace
    {
        get
        {
            return this.transform.GetChild(3).GetChild(1).gameObject.activeInHierarchy;
        }
        set
        {
            this.transform.GetChild(3).GetChild(1).gameObject.SetActive(value);
        }
    }

    public Sprite Box
    {
        get
        {
            return this.transform.GetChild(1).GetComponent<Image>().sprite;
        }
        set
        {
            this.transform.GetChild(1).GetComponent<Image>().sprite = value;
        }
    }

    public Sprite Icon
    {
        get
        {
            return this.transform.GetChild(0).GetComponent<Image>().sprite;
        }
        set
        {
            this.transform.GetChild(0).GetComponent<Image>().sprite = value;
        }
    }

    public int Level
    {
        get
        {
            return int.Parse(this.transform.GetChild(2).GetComponent<Text>().text);
        }
        set
        {
            this.transform.GetChild(2).GetComponent<Text>().text = value.ToString();
        }
    }

    public Sprite Race1
    {
        get
        {
            return this.transform.GetChild(3).GetChild(0).GetComponent<Image>().sprite;
        }
        set
        {
            this.transform.GetChild(3).GetChild(0).GetComponent<Image>().sprite = value;
        }
    }

    public Sprite Race2
    {
        get
        {
            if (isDoubleRace)
            {
                return this.transform.GetChild(3).GetChild(0).GetComponent<Image>().sprite;
            }
            else
            {
                return null;
            }
        }
        set
        {
            if (isDoubleRace)
                this.transform.GetChild(3).GetChild(0).GetComponent<Image>().sprite = value;
            else
                return;
        }
    }

    public Sprite Profession
    {
        get
        {
            return this.transform.GetChild(3).GetChild(2).GetComponent<Image>().sprite;
        }
        set
        {
            this.transform.GetChild(3).GetChild(2).GetComponent<Image>().sprite = value;
        }
    }

    private int star = 5;

    public int Star
    {
        get
        {
            return this.star;
        }
        set
        {
            star = value;
            if (star>=5)
            {
                star = 5;
            }else if(star <= 1){
                star = 1;
            }
            for (int i = 0; i <= this.transform.GetChild(4).childCount - 1; i++)
            {
                this.transform.GetChild(4).GetChild(i).gameObject.SetActive(true);
            }
            for (int i = this.transform.GetChild(4).childCount-1; i >= value; i--)
            {
                this.transform.GetChild(4).GetChild(i).gameObject.SetActive(false);
            }
        }
    }
}
